﻿<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="../Brushes.xaml"/>
    <!-- ResourceDictionary Source="Button.xaml"/ -->
  </ResourceDictionary.MergedDictionaries>

  <SolidColorBrush x:Key="ControlEnabledColor" Color="Beige" />

  <Style TargetType="{x:Type ToolBarTray}">
    <!-- BasedOn="{StaticResource {x:Type ToolBarTray}}" -->
    <Setter Property="Background" Value="{StaticResource ToolBarTrayBackground}" />
  </Style>

  <Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="{x:Type Button}" BasedOn="{x:Null}">
    <Setter Property="FocusVisualStyle" Value="{DynamicResource NuclearButtonFocusVisual}" />
    <Setter Property="Background" Value="{DynamicResource NormalBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}" />
    <Setter Property="Template" Value="{DynamicResource ButtonTemplate}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="MinHeight" Value="18"/>
    <Setter Property="MinWidth" Value="50"/>
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
  </Style>

  <Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}" TargetType="{x:Type CheckBox}">
    <Setter Property="SnapsToDevicePixels" Value="true" />
    <Setter Property="FocusVisualStyle" Value="{DynamicResource CheckBoxFocusVisual}" />
    <Setter Property="Background" Value="{DynamicResource NormalBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}" />
    <Setter Property="Template" Value="{DynamicResource CheckBoxTemplate}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
  </Style>

  <Style x:Key="{x:Static ToolBar.RadioButtonStyleKey}" TargetType="{x:Type RadioButton}">
    <Setter Property="SnapsToDevicePixels" Value="true" />
    <Setter Property="FocusVisualStyle" Value="{DynamicResource RadioButtonFocusVisual}" />
    <Setter Property="Background" Value="{DynamicResource NormalBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}" />
    <Setter Property="Template" Value="{DynamicResource RadioButtonTemplate}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Style.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground">
          <Setter.Value>
            <SolidColorBrush Color="{DynamicResource TopGradientSelectColor}" />
          </Setter.Value>
        </Setter>
      </Trigger>
    </Style.Triggers>
  </Style>

  <Style x:Key="{x:Static ToolBar.ComboBoxStyleKey}" TargetType="{x:Type ComboBox}">
    <Setter Property="SnapsToDevicePixels" Value="true" />
    <Setter Property="Template" Value="{DynamicResource ComboBoxTemplate}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
  </Style>

  <Style x:Key="{x:Static ToolBar.TextBoxStyleKey}" TargetType="{x:Type TextBox}">
    <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="AllowDrop" Value="true" />
    <Setter Property="Template" Value="{DynamicResource TextBoxTemplate}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/>
    <Setter Property="BorderBrush" Value="#FF000000"/>
  </Style>

  <LinearGradientBrush x:Key="ToolBarToggleButtonIsCheckedBackground" EndPoint="0,1" StartPoint="0,0">
    <GradientStop Color="#40F7F7F7" Offset="0"/>
    <GradientStop Color="#80FFFBFF" Offset="0.5"/>
    <GradientStop Color="#FFFFFFFF" Offset="1"/>
  </LinearGradientBrush>

  <LinearGradientBrush x:Key="ToolBarToggleButtonMouseOverBackground" EndPoint="0,1" StartPoint="0,0">
    <GradientStop Color="#20F7F7F7" Offset="0"/>
    <GradientStop Color="#40FFFBFF" Offset="0.5"/>
    <GradientStop Color="#FFFFFFFF" Offset="1"/>
  </LinearGradientBrush>

  <Style x:Key="{x:Static ToolBar.ToggleButtonStyleKey}" TargetType="{x:Type ToggleButton}">
    <Setter Property="FocusVisualStyle" Value="{DynamicResource NuclearButtonFocusVisual}" />
    <Setter Property="Background" Value="{DynamicResource NormalBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Style.Triggers>
      <Trigger Property="IsChecked" Value="True">
        <Setter Property="Background" Value="{StaticResource ToolBarToggleButtonIsCheckedBackground}" />
        <Setter Property="BorderBrush" Value="#FF808080" />
      </Trigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource ToolBarToggleButtonMouseOverBackground}" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Foreground" Value="White" />
      </Trigger>
    </Style.Triggers>
  </Style>


  <LinearGradientBrush x:Key="ToolBarHorizontalBackground" EndPoint="0,1" StartPoint="0,0">
    <GradientStop Color="#FFFFFF" Offset="0"/>
    <GradientStop Color="#FFFBFF" Offset="0.5"/>
    <GradientStop Color="#F7F7F7" Offset="1"/>
  </LinearGradientBrush>

  <LinearGradientBrush x:Key="ToolBarToggleButtonHorizontalBackground" EndPoint="0,1" StartPoint="0,0">
    <GradientStop Color="#ECECEC" Offset="0"/>
    <GradientStop Color="#DDDDDD" Offset="0.5"/>
    <GradientStop Color="#A0A0A0" Offset="1"/>
  </LinearGradientBrush>

  <SolidColorBrush x:Key="ToolBarButtonHover" Color="{StaticResource MainColor}" />
  <SolidColorBrush x:Key="ToolBarGripper" Color="#C6C3C6"/>

  <Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
    <Setter Property="Background" Value="{StaticResource ToolBarToggleButtonHorizontalBackground}"/>
    <Setter Property="MinHeight" Value="0"/>
    <Setter Property="MinWidth" Value="0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border SnapsToDevicePixels="true" x:Name="Bd" CornerRadius="0,0,0,0" Background="{DynamicResource LightBrush}">
            <Canvas SnapsToDevicePixels="true" HorizontalAlignment="Right" Margin="7,2,2,2" VerticalAlignment="Bottom" Width="6" Height="7">
              <Path Stroke="White" Data="M 1 1.5 L 6 1.5"/>
              <Path Stroke="{TemplateBinding Foreground}" Data="M 0 0.5 L 5 0.5"/>
              <Path Fill="White" Data="M 0.5 4 L 6.5 4 L 3.5 7 Z"/>
              <Path Fill="{TemplateBinding Foreground}" Data="M -0.5 3 L 5.5 3 L 2.5 6 Z"/>
            </Canvas>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="Bd" Value="{DynamicResource MouseOverBrush}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
              <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Foreground" Value="{StaticResource ToolBarGripper}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <SolidColorBrush x:Key="ToolBarSubMenuBackground" Color="#FFFDFDFD"/>
  <SolidColorBrush x:Key="ToolBarMenuBorder" Color="{StaticResource MenuBorder}"/>
  <Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
          <Border SnapsToDevicePixels="True" Background="Transparent" Padding="{TemplateBinding Padding}" CornerRadius="0,0,0,0">
            <Rectangle>
              <Rectangle.Fill>
                <DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" ViewboxUnits="Absolute" Viewport="0,0,4,4" ViewportUnits="Absolute">
                  <DrawingBrush.Drawing>
                    <DrawingGroup>
                      <GeometryDrawing Brush="White" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
                      <GeometryDrawing Brush="{StaticResource ToolBarGripper}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
                    </DrawingGroup>
                  </DrawingBrush.Drawing>
                </DrawingBrush>
              </Rectangle.Fill>
            </Rectangle>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Cursor" Value="SizeAll"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <LinearGradientBrush x:Key="ToolBarToggleButtonVerticalBackground" EndPoint="1,0" StartPoint="0,0">
    <GradientStop Color="#ECECEC" Offset="0"/>
    <GradientStop Color="#DDDDDD" Offset="0.5"/>
    <GradientStop Color="#A0A0A0" Offset="1"/>
  </LinearGradientBrush>

  <Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
    <Setter Property="Background" Value="{StaticResource ToolBarToggleButtonVerticalBackground}"/>
    <Setter Property="MinHeight" Value="0"/>
    <Setter Property="MinWidth" Value="0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="0,0,3,3">
            <Canvas SnapsToDevicePixels="true" HorizontalAlignment="Right" Margin="2,7,2,2" VerticalAlignment="Bottom" Width="7" Height="6">
              <Path Stroke="White" Data="M 1.5 1 L 1.5 6"/>
              <Path Stroke="{TemplateBinding Foreground}" Data="M 0.5 0 L 0.5 5"/>
              <Path Fill="White" Data="M 3.5 0.5 L 7 3.5 L 4 6.5 Z"/>
              <Path Fill="{TemplateBinding Foreground}" Data="M 3 -0.5 L 6 2.5 L 3 5.5 Z"/>
            </Canvas>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
              <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Foreground" Value="{StaticResource ToolBarGripper}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <LinearGradientBrush x:Key="ToolBarVerticalBackground" EndPoint="1,0" StartPoint="0,0">
    <GradientStop Color="#FFFFFF" Offset="0"/>
    <GradientStop Color="#FFFBFF" Offset="0.5"/>
    <GradientStop Color="#F7F7F7" Offset="1"/>
  </LinearGradientBrush>

  <Style TargetType="{x:Type ToolBar}">
    <Setter Property="Background" Value="{StaticResource ToolBarHorizontalBackground}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToolBar}">
          <Grid SnapsToDevicePixels="true" Margin="3,1,1,1" x:Name="Grid">
            <Grid HorizontalAlignment="Right" x:Name="OverflowGrid">
              <ToggleButton IsEnabled="{TemplateBinding HasOverflowItems}"
                            FocusVisualStyle="{x:Null}"
                            x:Name="OverflowButton"
                            Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}"
                            ClickMode="Press"
                            IsChecked="{Binding Path=IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
              <Popup Focusable="false" AllowsTransparency="true" IsOpen="{Binding Path=IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" StaysOpen="False" x:Name="OverflowPopup">
                <Border x:Name="Shdw">
                  <Border BorderThickness="1,1,1,1" Background="{DynamicResource LightBrush}" BorderBrush="{DynamicResource LightBrush}">
                    <ToolBarOverflowPanel Focusable="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" FocusVisualStyle="{x:Null}" Margin="2" x:Name="PART_ToolBarOverflowPanel" WrapWidth="200" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle"/>
                  </Border>
                </Border>
              </Popup>
            </Grid>
            <Border Margin="0,0,11,0" x:Name="MainPanelBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0,0,0,0" Padding="{TemplateBinding Padding}" Background="{DynamicResource NormalBorderBrush}">
              <Grid>

                <DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
                  <Thumb Padding="6,5,1,6" Margin="-3,-1,0,0" x:Name="ToolBarThumb" Style="{StaticResource ToolBarThumbStyle}" Width="10"/>
                  <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Center" Margin="4,0,4,0" x:Name="ToolBarHeader" VerticalAlignment="Center" ContentSource="Header"/>
                  <ToolBarPanel SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,1,2,2" x:Name="PART_ToolBarPanel" IsItemsHost="true" Background="{DynamicResource NormalBrush}"/>
                </DockPanel>
                <Rectangle IsHitTestVisible="False" Opacity="0.15" VerticalAlignment="Top" Height="13.995" Grid.ColumnSpan="1" Margin="0,0,2,0">
                  <Rectangle.Fill>
                    <SolidColorBrush Color="{DynamicResource WhiteColor}"/>
                  </Rectangle.Fill>
                </Rectangle>
              </Grid>
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsOverflowOpen" Value="true">
              <Setter Property="IsEnabled" TargetName="ToolBarThumb" Value="false"/>
            </Trigger>
            <Trigger Property="Header" Value="{x:Null}">
              <Setter Property="Visibility" TargetName="ToolBarHeader" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="ToolBarTray.IsLocked" Value="true">
              <Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="HasDropShadow" SourceName="OverflowPopup" Value="true">
              <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
              <Setter Property="SnapsToDevicePixels" TargetName="Shdw" Value="true"/>
              <Setter Property="Background" TargetName="Shdw" Value="#71000000"/>
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
              <Setter Property="Margin" TargetName="Grid" Value="1,3,1,1"/>
              <Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
              <Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
              <Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
              <Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
              <Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1"/>
              <Setter Property="Margin" TargetName="ToolBarHeader" Value="0,0,0,4"/>
              <Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="1,0,2,2"/>
              <Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top"/>
              <Setter Property="DockPanel.Dock" TargetName="ToolBarHeader" Value="Top"/>
              <Setter Property="HorizontalAlignment" TargetName="OverflowGrid" Value="Stretch"/>
              <Setter Property="VerticalAlignment" TargetName="OverflowGrid" Value="Bottom"/>
              <Setter Property="Placement" TargetName="OverflowPopup" Value="Right"/>
              <Setter Property="Margin" TargetName="MainPanelBorder" Value="0,0,0,11"/>
              <Setter Property="Background" Value="{StaticResource ToolBarVerticalBackground}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
  </Style>

</ResourceDictionary>
